﻿import game.Main;
import game.SandClock;
import game.Session;
import mx.utils.Delegate;
/**
* ...
* @author Default
*/

class game.IntroScreen {
		
	private var _mcIntroScreen:MovieClip;
	private var _mcContainer:MovieClip
	
	public function IntroScreen( container:MovieClip) {
		
		_mcContainer = container;
		
		_mcIntroScreen = container.attachMovie("intro", "intro", container.getNextHighestDepth() );
		_mcIntroScreen.back.onRelease = new Function();
		_mcIntroScreen.back.enabled = false;
		_mcIntroScreen._sbtPlay.onRelease = Delegate.create(this, onClickPlay);
		_mcIntroScreen._sbtPlay.onRollOver = Delegate.create(this, onOver);
		_mcIntroScreen.finish = Delegate.create(this, onFinish);
		
		Main.getInstance()._cSoundManager.intro1Start();
		
	}
	
	private function onOver():Void {
		Main.getInstance()._cSoundManager.overStart();
	}
	
	private function onClickPlay():Void {
		Main.getInstance()._cSoundManager.clickStart();
		_mcIntroScreen.gotoAndPlay("fadeout");
	}
	
	private function onFinish():Void {
		Main.getInstance()._cSoundManager.intro1Stop();
		Main.getInstance()._cGUI.showTheme();
		Main.getInstance()._cGUI.showHelp( this, hideEmptyTheme);
		//Main.getInstance()._cGUI.showHelp(Session.getInstance(), Session.getInstance().firstMatch );
	}
	
	private function hideEmptyTheme() {
		Main.getInstance()._cGUI.hidingTheme();
		SandClock.create( 30 , Delegate.create(this, onFinishHiding) );
	}
	
	private function onFinishHiding():Void {
		Session.getInstance().firstMatch();
	}
	
}